---
author: hongbo
date: "2019-09-23"
previewImg:
badge: release
title: Announcing BuckleScript 5.2.0 / 6.2.0
description: |
---

## New Release

`bs-platform` 5.2.0/6.2.0 is released, it contains several major enhancement
that we would like to share with you.

You can install it via `npm i -g bs-platform@5.2.0`

## Local module compiled into object

OCaml has an [advanced module
system](https://people.mpi-sws.org/~dreyer/thesis/old/thesis050405.pdf) for
people to structure large scale applications, it supports first class module
and higher-order module system which is unique compared to other ML-like
languages such as F# and Haskell.

In previous versions, BuckleScript compiled local modules into a JS array
whereby global modules (module produced by a file)were transformed into JS
objects.

When a local module is compiled into a JS array, the field name is stripped
away, which makes debugging and JS interop difficult. To make the debugging
experience better, we instrumented the array with field names in debug mode,
this mitigated the debugging issue, but still present challenges for JS
interop.

In this release, the compiler generates uniform representation for global
module and local module -- idiomatic JS object, this makes OCaml's module
system more valuable to JS target.

Below is an image showing the diff in this release

<img src="https://bucklescript.github.io/img/functor.avif" />

As you can see, the `id` module changed from an array into an JS object.

## Pattern match code generation with annotations

BuckleScript aims to generate readable code.

OCaml has a sophiscated pattern match compiler, it generates well optimized
code, however, for complex pattern matching, the constructor name is lost on
native backend, this is also one of the very few case where we generate magic
number in JS backend, this makes debugging particularly challenging for large
complex pattern match.

In this release, we made such information available to JS backend so that we
annotate the generated JS code with its names.

Below is an image showing the diff in this release

<img src="https://bucklescript.github.io/img/pattern-match.avif" />

In the future, we will explore if we can produce such annotation in the runtime without losing efficiency.

## Code generation improvement in various places

We care about the generated code quality, and will always keep improving it
regardless how good it is.

In this release, we improved the code generation in quite a lot of places
including lazy evaluation, if branches and pattern match.

In particular, we added a data-flow pass to eliminate non-necessary staticfail
case.

<img src="https://bucklescript.github.io/img/staticfail.avif" />

## Important bug fixes

This release also comes with a couple of important bug fixes, in particular,
#3805 the stale build issue and #3823 the interaction with reason langauge
service.

## Upcoming breaking changes

In next release, we plan to [remove deprecated
getters](https://reasonml.chat/t/ann-remove-deprecated-getters-in-deriving-abstract-after-5-2-0/1908).

A detailed list of changes is available
[here](https://github.com/BuckleScript/bucklescript/blob/master/Changes.md#520)

Happy hacking!
